// 创建用户仓库模块并导出
import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { User } from '@/types/user'
// use+模块名+store
export const useUserStore = defineStore(
  'user',
  () => {
    const user = ref<User>()
    // 存储用户信息
    const setUser = (info: User) => {
      user.value = info
    }
    // 删除用户信息
    const delUser = () => {
      user.value = undefined
    }
    const URL = ref('')
    const setURL = (str: string) => {
      URL.value = str
    }
    return {
      user,
      setUser,
      delUser,
      setURL,
      URL
    }
  },
  {
    persist: true // 可以将persist设置为一个对象做额外的配置
  }
)
